import Common from '../../../common/common.js';
let common = new Common;
const app = getApp();

Page({
  data: {
pageNumber:1,
    pageList:[],//数据 列表
    isEnd: false, //是否到底
  },
   onLoad: function (options) {
    this.getPageList(1, 1);
    // this.queryDeliverStatus();
  },
  onShow: function () { },
  // 跳转详情
  problemDetil:function(e){
   console.log(e);
    wx.navigateTo({
        url: '/pages/myCenter/problemDetil/problemDetil?id='+e.currentTarget.dataset.id+'&name='+e.currentTarget.dataset.name+'&type='+0,
    })
  },
  getPageList(page, type) {
    let data = {
       "size": 10,
    "current": page,
    "condition": {
    },
    "ascs": [],
    "descs": []
    }
    common.requestAjax('/api/promotion-service/v1/faq/qryFaq', 'POST', data).then(res => {
      if (res.data.code) {
        console.log(res.data.records,'列表数据');
        let arraylist = this.data.pageList || [];
        let isEnd = this.data.isEnd;
        if (type == 1) {
          //下拉刷新
          arraylist = res.data.records;
          isEnd = false;
        } else if (type == 2) {
          //上拉加载
          arraylist = arraylist.concat(res.data.records);
          if (res.data.records.length == 0) {
            //最后一行没数据 到底了
            isEnd = true;
          }
          setTimeout(() => {
            wx.hideLoading()
          }, 500)
        }
        this.setData({
          pageList: arraylist,
          isEnd,
        })
      }

    })
  },
  onReachBottom: function () {
    if (!this.data.isEnd) {
      let pageNumber = this.data.pageNumber;
      pageNumber += 1;

      this.getPageList(pageNumber, 2)

      wx.showLoading({
        title: '正在加载中...',
      })
      this.setData({
        pageNumber
      })
    }
  },
})